package com.banyuan.HomeWork.string;

import java.util.Arrays;

//将字符串“aAbBcCdDeE“中所有的小写字符转成大写字符，大写字符转成小写字符，生成一个新的字符串；
public class five {
    public static void main(String[] args) {
        String s1 = "aAbBcCdDeE";
        char[] arr1 = s1.toCharArray();
        for (int i = 0; i < arr1.length; i++) {
            if(arr1[i] >= 'a' && arr1[i] <= 'z'){
                arr1[i] -= 32;
            }

            //必须要else if让上面的判断不进入下面的判断
            else if(arr1[i] >= 'A' && arr1[i] <= 'Z'){
                arr1[i] += 32;
            }
        }

        String s2 = String.valueOf(arr1);
        System.out.println(s2);
    }
}
